package C_Paper;

import java.util.Arrays;

public class C100_9 {
    //披萨
    public static void main(String[] args) {
        s(new int[]{3,15,6,14,2});
    }
    public static void s(int[] price){
        int[] tex = new int[price.length];
        int i = price.length;
        for (int j = 0; j < i; j++) {
            int pr = 0;
            int p = j+1;
            while(true){
                if (p == i){
                    p = 0;
                }
                if (price[p] < price[j]){
                    pr = price[p];
                    break;
                }
                if (p == j){
                    break;
                }
                p++;
            }
            tex[j] = pr + price[j];
        }
        System.out.println(Arrays.toString(tex));
    }
}
